// 设置jQuery Ajax全局的参数
$.ajaxSetup({
    type: "POST",
    error: function(jqXHR, textStatus, errorThrown){
        switch (jqXHR.status){
            case(500):
                $.messager.alert("提示","服务器系统内部错误！","error");
                break;
            case(401):
                $.messager.alert("提示","未登录！","error");
                break;
            case(403):
                $.messager.alert("提示","无权限执行此操作！","error");
                break;
            case(408):
                $.messager.alert("提示","请求超时！","error");
                break;
            case(404):
                $.messager.alert("提示","请求链接不存在！","error");
                break;
            default:
                $.messager.alert("提示","未知错误！","error");
        }
    },
    success: function(data){
    }
});

var RequestUtils={
  get:function (key) {
      var href=window.location.href;
      var params=href.split("?")[1];
      params=params.split("&");
      for(var i=0;i<params.length;i++){
          var p=params[i];
          p=p.split("=");
          if(p[0]==key){
              return decodeURI(p[1]);
          }
      }
      return "";
  },
  getId:function () {
      return this.get("id");
  }
};

function ajaxGet(url,data){
    $.ajaxSettings.async=false;
    $.getJSON(url,data,function (d) {
        data=d;
    });
    return data;
}

function ajaxPost(url,data){
    $.ajaxSettings.async=false;
    $.post(url,data,function (d) {
        data=d;
    });
    return data;
}